/*
 * @Author: lixiaowei
 * @Date: 2021-04-09 13:49:10
 * @LastEditors: lixiaowei
 * @LastEditTime: 2021-04-09 14:05:20
 * @Description: 序列式容器及仿函数
 * @FilePath: /heima-bli/STL/序列式容器.cpp
 */

#include <iostream>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

struct Display
{
  void operator()(int i)
  {
    cout << i << " ";
  }
};

int main()
{
  int nums[] = {1, 2, 3, 4, 5};

  vector<int> iVector(nums, nums + 4);
  list<int> iList(nums, nums + 4);
  deque<int> iDeque(nums, nums + 4);
  queue<int> iQueue(iDeque);
  stack<int> iStack(iDeque);
  priority_queue<int> iPQueue(nums, nums + 4);

  for_each(iVector.begin(), iVector.end(), Display());
  cout << endl;
  for_each(iList.begin(), iList.end(), Display());
  cout << endl;
  for_each(iDeque.begin(), iDeque.end(), Display());
  cout << endl;
  while (!iQueue.empty())
  {
    cout << iQueue.front() << " ";
    iQueue.pop();
  }
  cout << endl;

  while (!iStack.empty())
  {
    cout << iStack.top() << " ";
    iStack.pop();
  }

  cout << endl;

  while (!iPQueue.empty())
  {
    cout << iPQueue.top() << " ";
    iPQueue.pop();
  }

  cout << endl;
  
  

  return 0;
}